//
//  AffResult.cpp
//  Taquin
//
//  Created by Benjamin Bouachour on 17/08/11.
//  Copyright 2011 Epitech. All rights reserved.
//

#include <list>
#include "AffResult.h"


const void AffResult::affEtat(const Etat *etat)
{
    if (etat) 
    {
        tgrid grid = etat->getGrid();
        for (int y = 0; y < etat->getSize(); ++y) 
        {
            for (int x = 0; x < etat->getSize(); ++x)
            {
                cout << (grid.find(pair<int, int>(x, y)))->second;
            }
            cout << endl;
        }
        cout << "Heuristique = " << etat->getQualite() << endl;
        cout << "Distance " << etat->getDistance()<< endl;
        cout << endl;
    }
}

const int AffResult::AffStar(const Etat *etat)
{
    AffResult res;
    int count = 0;
//    const Etat *etat = close_list.end()->second;
	 list<const Etat*> result;
    while (etat != NULL)
    {
        //res.affEtat(etat);
		result.push_back(etat);
		etat = etat->getParent();
        count++;
    }

	list<const Etat*>::iterator it;
	for (it = result.begin(); it != result.end(); ++it)
		res.affEtat(*it);
    return count;
//    a_list::const_iterator it;
//    for(it = close_list.begin(); it != close_list.end(); ++it)
//    {
//        res.affEtat(it->second);
//    }
    
}

